import { View } from '@tarojs/components';
import './index.less';

interface IProps {
  className?: string;
  bgColor?: string;
  title?: string;
  size?: 'normal' | 'small' | 'large' | 'middle';
  onClick?: Function;
}

const ButtonComp = (props: IProps) => {
  const {
    className = '',
    bgColor = 'var(--mini-first)',
    title = '',
    size = 'normal',
  } = props;

  const handleTap = () => {
    if (props.onClick) {
      props.onClick();
    }
  };

  return (
    <View
      className={ `${ className } ${ size } button-comp-container` }
      style={ {backgroundColor: bgColor} }
      onTap={ handleTap }
    >
      { title }
    </View>
  );
};

export default ButtonComp;